import 'package:flutter/material.dart';
import 'package:ycbl/config/bl_color.dart';

/// 圆角 + 边框 + 背景色按钮
class BLBorderButton extends StatelessWidget {

  /// 按钮中的控件，一般是 Text
  final Widget child;
  /// 圆角大小 默认 20
  final double radius;
  /// 边框颜色
  final Color borderColor;
  /// 边框粗细 默认 1
  final double borderWidth;
  /// 按钮背景色
  final Color backgroundColor;
  /// 按下时的颜色
  final Color highlightColor;
  /// 内边距
  final EdgeInsetsGeometry padding;
  /// 点击
  final VoidCallback onPressed;

  const BLBorderButton({
    Key key,
    this.radius = 20,
    this.borderColor = BLColor.tabSelectBorderColor,
    this.borderWidth = 1,
    this.backgroundColor = BLColor.tabSelectBgColor,
    this.highlightColor,
    this.onPressed,
    this.child,
    this.padding,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Ink(
      decoration: BoxDecoration(
          border: Border.all(
            color: borderColor,
            width: borderWidth
          ),
          borderRadius: BorderRadius.all(Radius.circular(radius)),
          color: backgroundColor
      ),

      child: InkWell(
        // 和 Ink 设置想用的圆角，这样水波纹效果就不会溢出
        borderRadius: BorderRadius.all(Radius.circular(radius)),
        child: Padding(
          padding: padding ?? EdgeInsets.fromLTRB(20, 4, 20, 4,),
          child: Center(
            widthFactor: 1,
            child: child,
          ),
        ),
        onTap: onPressed,
        //按下时的颜色
        highlightColor: highlightColor,
      ),
    );
  }
}
